#include <iostream>
#include <list>

using std::list;
using std::cout;
using std::endl;

void test(){
    list<int> number;

    list<int> number1(10);
    list<int> number2(10,1);

    int arr[10] = {9,8,7,6,5,4,3,2,1,0};
    list<int> number3(arr,arr+10);

    list<int> number4 = {0,1,2,3,4,5,6,7,8,9};

    //利用下标遍历 //error  list相当于链表，没有下标，
    /* for(int index = 0; index < number4.size();++index){ */
    /*     cout << number4[index] << " "; */
    /* } */
    /* cout << endl; */
    
    //迭代器遍历
    list<int>::iterator it;
    for(it = number4.begin();it!=number4.end();++it){
        cout << *it << " ";
    }
    cout << endl;

    /* for(list<int>::iterator it2 =number4.begin();it2 != number4.end();++it2) */
    list<int>::iterator it2 =number4.begin();
    for(;it2 != number4.end();++it2){
        cout << *it2 << " ";
    }
    cout <<endl;

    //第二种迭代器遍历方式
    /* while(it != number4.end()){ */
    /*     cout << *it << " "; */
    /* } */
    /* cout << endl; */

    //增强for循环遍历
    for(auto &ele:number4){
        cout << ele << " ";
    }
    cout << endl;


}

int main()
{
    test();
    return 0;
}

